import {Global, Module} from "@nestjs/common";
import {JwtModule} from "@nestjs/jwt";
import {JWT_EXPIRES, JWT_SECRET} from "@/conf/authConf";
import {APP_INTERCEPTOR} from "@nestjs/core";
import {GlobalGuard} from "@/modules/jwtModule/service/global.guard";
import {AuthService} from "@/modules/jwtModule/service/auth.service";

@Global()
@Module({
    imports: [
        JwtModule.register({
            secret: JWT_SECRET, // jwt秘钥
            signOptions: {
                expiresIn: JWT_EXPIRES, // jwt有效期
            }
        }),
    ],
    providers: [
        {
            provide: APP_INTERCEPTOR,
            useClass: GlobalGuard,
        },
        AuthService,
    ],
    exports: [
        AuthService
    ],
})
export class JwtComplyModule {}
